//
//  HomePageViewController.m
//  YellowBridge
//
//  Created by 王右 on 2018/12/1.
//  Copyright © 2018 王右. All rights reserved.
//

#import "HomePageViewController.h"
#import "HomePageTableViewCell.h"
#import "ProjectDataBaseViewController.h"
#import "VideoListViewController.h"
#import "UserCenterViewController.h"

@interface HomePageViewController ()


@property (weak, nonatomic) IBOutlet UIView *containerView;

@property (weak, nonatomic) IBOutlet UITableView *baseTableView;
@property (weak, nonatomic) IBOutlet UIView *shadowView;

@property (nonatomic, strong) NSArray *dataArr;

@end

@implementation HomePageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    if (@available(iOS 11, *)) {
        self.baseTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else{
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
    
    
    self.title = @"黄桥项目系统";
    [self configContainerViewShadow];    
    _dataArr = @[@"工程项目",@"视频管理",@"个人中心"];
    [_baseTableView reloadData];
}

- (void)configContainerViewShadow{
    
    _containerView.layer.shadowColor = [UIColor colorWithHexString:@"#74D18C"].CGColor;
    _containerView.layer.shadowOffset = CGSizeMake(2,3);
    _containerView.layer.shadowOpacity = 0.8;
    _containerView.layer.shadowRadius = 4;
    
    _shadowView.layer.shadowColor = [UIColor colorWithHexString:@"#74D18C"].CGColor;
    _shadowView.layer.shadowOffset = CGSizeMake(-3,-2);
    _shadowView.layer.shadowOpacity = 0.8;
    _shadowView.layer.shadowRadius = 4;
    
    _baseTableView.layer.cornerRadius = 2;
    _baseTableView.layer.masksToBounds = YES;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 52;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    HomePageTableViewCell *cell = (HomePageTableViewCell *)[tableView cellWithCellNibName:@"HomePageTableViewCell"];
    cell.iconImageView.image = [UIImage imageNamed:_dataArr[indexPath.row]];
    cell.nameLabel.text = _dataArr[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row==0) {
        [self.navigationController pushViewController:[ProjectDataBaseViewController new] animated:YES];
    }else if (indexPath.row==1){
        [self.navigationController pushViewController:[VideoListViewController new] animated:YES];
    }else{
        [self.navigationController pushViewController:[UserCenterViewController new] animated:YES];
    }
}
@end
